package com.sts.service.impl;

import com.sts.dto.PermissionDTO;
import com.sts.mapper.PermissionMapper;
import com.sts.service.AuthService;
import com.sts.service.PermissionService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class PermissionServiceImpl implements PermissionService {
    private final PermissionMapper permissionMapper;
    @Override
    public List<PermissionDTO> list() {
        return permissionMapper.selectList(null)
                .stream()
                .map(p-> PermissionDTO.builder()
                        .id(p.getId())
                        .permName(p.getPermName())
                        .permCode(p.getPermCode())
                        .description(p.getDescription())
                        .createdAt(p.getCreatedAt())
                        .build())
                .collect(Collectors.toList());
    }
}
